<template>
    <div>

 <h1>登录</h1>
<table class="table">
    <tbody>
<tr>
    <td>姓名</td>
    <td>
        <input type="text" v-model="sa.username">
    </td>
</tr>

<tr>
    <td>密码</td>
    <td>
        <input type="password" v-model="sa.password">
    </td>
</tr>

<tr>
    <td></td>
    <td>
        <input type="button" value="登录" @click="dl">
    </td>
</tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref } from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const uu=useRouter()

const sa=ref({
    username:"",
    password:""
})

const dl=()=>{
    axios.get("https://localhost:7097/api/Hy/Login",{params:sa.value}).then(res=>{
        if(res.data.id==-1){
            alert("用户名不存在")
        }
        if(res.data.id==-2){
            alert("密码错误")
        }
        if(res.data.id>0){
            alert("登录成功")
uu.push({path:'/'})
        }
    })
}
</script>

<style scoped>

</style>